package com.springboot.domain;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.Value;
import org.hibernate.annotations.GeneratorType;

import javax.persistence.*;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import java.util.Date;

@Entity
@Table(name="ssm_operation_log")
@Data
@AllArgsConstructor   //有参构造
//@NoArgsConstructor    //无参构造
public class OperationLog {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "id")
    private Integer id;
    @Column(name = "user_id")
    private String operationUser;
    @Column(name = "create_time")
    private Date operationTime;
    @Column(name="ip_address")
    private String ip;
    @Column(name = "type")
    @NotNull
    private String operationType;
    @Column(name = "unit")
    @NotNull
    private String operationUnit;

    public OperationLog(String operationUser, @NotEmpty Date operationTime,
                        String ip, @NotNull String operationType,
                        @NotNull String operationUnit) {
        this.operationUser = operationUser;
        this.operationTime = operationTime;
        this.ip = ip;
        this.operationType = operationType;
        this.operationUnit = operationUnit;
    }
}
